//index.js
//获取应用实例
import {groupApi} from "../../model/aliyun/group";
const app = getApp();

Page({
  data: {

  },
  onLoad: function () {
      wx.showLoading({
          title: '努力加载中...',
          mask: true
      });
      this.loadGroupList();
  },

  loadGroupList () {
      groupApi.queryDeviceGroupList({
          PageSize: 50,
          CurrentPage: 1
      }).then((res) => {
          console.log(res);
          if (res.Data && res.Data.GroupInfo) {
              this.handleGroupList(res.Data.GroupInfo);
              // 判断是否需要继续请求
              if (res.PageCount > this._data.CurrentPage) {
                  this._data.CurrentPage ++;
                  this.queryDevice(this._data.PageSize, this._data.CurrentPage);
              } else {
                  this.finishQueryDevice();
              }
          } else {
              this.finishQueryDevice();
          }
      }).catch( err => {
          console.log(err);
      });
  }

});
